<?php

namespace App\Models;

use Illuminate\Database\Eloquent\Model;

/**
 * App\Models\Role
 *
 * @mixin \Eloquent
 */
class Role extends Model
{
    protected $fillable = [
        'name',
    ];
    /**
     * 建立与 permission 关联关系
     */
    public function perms()
    {
        return $this->belongsToMany(Permission::class);
    }

    public function givePermissionTo($permission)
    {
        return $this->perms()->save($permission);
    }

}
